#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <fstream>
#include <sstream>
#include <cctype>
#include <iostream>
#include <map>



std::vector<std::string> MainWindow::LoadValue(const std::string& line, int count, int spacesNum)
{
    std::vector<std::string> num;

    for (int j = 0; j < count; ++j)
    {
        if (spacesNum*j + 1 + spacesNum > static_cast<int>(line.length()))
        {
            num.push_back("");
        }
        else
        {
            std::string snum(line, spacesNum*j + 1, spacesNum);
            snum.erase(std::remove_if(snum.begin(), snum.end(), static_cast<int(&)(int)>(std::isspace)), snum.end());
            num.push_back(snum);
        }
    }

    return num;
}



void MainWindow::Load()
{

    std::string line;
    std::map<std::string, std::string> props;
    std::ifstream file(inFile.toStdString().c_str());

    while (std::getline(file, line))
    {
        std::string token;
        std::istringstream tokens(line);
        while (tokens >> token)
        {
            std::size_t pos = token.find('*');
            if (pos != std::string::npos)
            {

                if (token == "*TITLE")
                {
                    std::getline(file, line);
                    ui->titleLineEdit->setText(QString::fromStdString(line));
                }

                else if (token == "*PARAMETER")
                {

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    ui->dpPRMR1lineEdit->setText(num[0].c_str());
                    ui->dpVAL1lineEdit->setText(num[1].c_str());
                    ui->dpPRMR2lineEdit->setText(num[2].c_str());
                    ui->dpVAL2lineEdit->setText(num[3].c_str());
                    ui->dpPRMR3lineEdit->setText(num[4].c_str());
                    ui->dpVAL3lineEdit->setText(num[5].c_str());
                    ui->dpPRMR4lineEdit->setText(num[6].c_str());
                    ui->dpVAL4lineEdit->setText(num[7].c_str());
                }

                else if (token == "*CONTROL_TERMINATION")
                {

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 5, VAL_DIST);

                    ui->ctENDTIMlineEdit->setText(num[0].c_str());
                    ui->ctENDCYClineEdit->setText(num[1].c_str());
                    ui->ctDTMINlineEdit->setText(num[2].c_str());
                    ui->ctENDNEGlineEdit->setText(num[3].c_str());
                    ui->ctENDMASlineEdit->setText(num[4].c_str());
                }

                else if (token == "*CONTROL_TIMESTEP")
                {

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 3, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    ui->ctDTINITlineEdit->setText(num[0].c_str());
                    ui->ctTSSFAClineEdit->setText(num[1].c_str());
                    ui->ctISDOlineEdit->setText(num[2].c_str());
                    ui->ctTSLIMTlineEdit->setText(num[3].c_str());
                    ui->ctDT2MSlineEdit->setText(num[4].c_str());
                    ui->ctLCTMlineEdit->setText(num[5].c_str());
                    ui->ctERODElineEdit->setText(num[6].c_str());
                    ui->ctMS1STlineEdit->setText(num[7].c_str());
                    ui->ctDT2MSFlineEdit->setText(num[8].c_str());
                    ui->ctDT2MSLClineEdit->setText(num[9].c_str());
                    ui->ctIMSCLlineEdit->setText(num[10].c_str());
                }

                else if (token == "*CONTROL_RIGID")
                {

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 6, VAL_DIST);

                    ui->crLMFlineEdit->setText(num[0].c_str());
                    ui->crJNTFlineEdit->setText(num[1].c_str());
                    ui->crORTHMDlineEdit->setText(num[2].c_str());
                    ui->crPARTMlineEdit->setText(num[3].c_str());
                    ui->crSPARSElineEdit->setText(num[4].c_str());
                    ui->crMETALFlineEdit->setText(num[5].c_str());
                }

                else if (token == "*CONTROL_HOURGLASS")
                {

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 2, VAL_DIST);

                    ui->chIHQlineEdit->setText(num[0].c_str());
                    ui->chHQlineEdit->setText(num[1].c_str());
                }

                else if (token == "*CONTROL_BULK_VISCOSITY")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 3, VAL_DIST);

                    ui->cbvQ1lineEdit->setText(num[0].c_str());
                    ui->cbvQ2lineEdit->setText(num[1].c_str());
                    ui->cbvTypelineEdit->setText(num[2].c_str());
                }

                else if (token == "*CONTROL_SHELL")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 7, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num3 = LoadValue(line, 2, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());
                    num.insert(num.end(), num3.begin(), num3.end());

                    ui->csWRPANGlineEdit->setText(num[0].c_str());
                    ui->csESORT_1lineEdit->setText(num[1].c_str());
                    ui->csIRNXXlineEdit->setText(num[2].c_str());
                    ui->csISTUPDlineEdit->setText(num[3].c_str());
                    ui->csTHEORYlineEdit->setText(num[4].c_str());
                    ui->csBWClineEdit->setText(num[5].c_str());
                    ui->csMITERlineEdit->setText(num[6].c_str());
                    ui->csPROJlineEdit->setText(num[7].c_str());
                    ui->csROTASCLlineEdit->setText(num[8].c_str());
                    ui->csINTGRDlineEdit->setText(num[9].c_str());
                    ui->csLAMSHTlineEdit->setText(num[10].c_str());
                    ui->csCSTYP6lineEdit->setText(num[11].c_str());
                    ui->csTSHELLlineEdit->setText(num[12].c_str());
                    ui->csNFAIL1lineEdit->setText(num[13].c_str());
                    ui->csNFAIL4lineEdit->setText(num[14].c_str());
                    ui->csPSSTUPDlineEdit->setText(num[15].c_str());
                    ui->csIRQUADlineEdit->setText(num[16].c_str());
                }

                else if (token == "*CONTROL_SOLID")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 4, VAL_DIST);

                    ui->csESORT_2lineEdit->setText(num[0].c_str());
                    ui->csFMATRXlineEdit->setText(num[1].c_str());
                    ui->csNIPTETSlineEdit->setText(num[2].c_str());
                    ui->csSWLOCLlineEdit->setText(num[3].c_str());
                }

                else if (token == "*CONTROL_CONTACT")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 7, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    ui->ccSLSFAClineEdit->setText(num[0].c_str());
                    ui->ccRWPNALlineEdit->setText(num[1].c_str());
                    ui->ccISLCHKlineEdit->setText(num[2].c_str());
                    ui->ccSHLTHKlineEdit->setText(num[3].c_str());
                    ui->ccPENOPTlineEdit->setText(num[4].c_str());
                    ui->ccTHKCHGlineEdit->setText(num[5].c_str());
                    ui->ccORIENlineEdit->setText(num[6].c_str());
                    ui->ccUSRSTRlineEdit->setText(num[7].c_str());
                    ui->ccUSRFAClineEdit->setText(num[8].c_str());
                    ui->ccNSBCSlineEdit->setText(num[9].c_str());
                    ui->ccINTERMlineEdit->setText(num[10].c_str());
                    ui->ccXPENElineEdit->setText(num[11].c_str());
                    ui->ccSSTHKlineEdit->setText(num[12].c_str());
                    ui->ccECDTlineEdit->setText(num[13].c_str());
                    ui->ccTIEDRPJlineEdit->setText(num[14].c_str());
                }

                else if (token == "*CONTROL_ENERGY")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 4, VAL_DIST);

                    ui->ceHGENlineEdit->setText(num[0].c_str());
                    ui->ceRWENlineEdit->setText(num[1].c_str());
                    ui->ceSLNTENlineEdit->setText(num[2].c_str());
                    ui->ceRYLENlineEdit->setText(num[3].c_str());
                }

                else if (token == "*CONTROL_OUTPUT")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 7, VAL_DIST);

                    ui->coNPOPTlineEdit->setText(num[0].c_str());
                    ui->coNEECHOlineEdit->setText(num[1].c_str());
                    ui->coNREFUPlineEdit->setText(num[2].c_str());
                    ui->coIACCOPlineEdit->setText(num[3].c_str());
                    ui->coOPIFSlineEdit->setText(num[4].c_str());
                    ui->coIPNINTlineEdit->setText(num[5].c_str());
                    ui->coIKEDITlineEdit->setText(num[6].c_str());
                }

                else if (token == "*CONTROL_PARALLEL")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 3, VAL_DIST);

                    ui->cpNCPUlineEdit->setText(num[0].c_str());
                    ui->cpNUMRHSlineEdit->setText(num[1].c_str());
                    ui->cpCONSTlineEdit->setText(num[2].c_str());
                }

                else if (token == "*CONTROL_ACCURACY")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 2, VAL_DIST);

                    ui->caOSUlineEdit->setText(num[0].c_str());
                    ui->caINNlineEdit->setText(num[1].c_str());
                }

                else if (token == "*INTERFACE_SPRINGBACK_LSDYNA")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 2, VAL_DIST);

                    ui->islPSIDlineEdit->setText(num[0].c_str());
                    ui->islNSHVlineEdit->setText(num[1].c_str());
                }

                else if (token == "*DATABASE_RCFORC")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dRCFORClineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_MATSUM")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dMATSUMlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_GLSTAT")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dGLSTATlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_SLEOUT")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dSLEOUTlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_RBDOUT")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dRBDOUTlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_BNDOUT")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dBNDOUTlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_ABSTAT")
                {
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 1, VAL_DIST);

                    ui->dABSTATlineEdit->setText(num[0].c_str());
                }

                else if (token == "*DATABASE_BINARY_D3PLOT")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 3, VAL_DIST);

                    ui->dbdDTCYCLlineEdit->setText(num[0].c_str());
                    ui->dbdLCDTlineEdit->setText(num[1].c_str());
                    ui->dbdBEAMlineEdit->setText(num[2].c_str());
                }

                else if (token == "*DATABASE_EXTENT_BINARY")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 6, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    ui->debNEIPHlineEdit->setText(num[0].c_str());
                    ui->debNEIPSlineEdit->setText(num[1].c_str());
                    ui->debMAXINTlineEdit->setText(num[2].c_str());
                    ui->debSTRFLGlineEdit->setText(num[3].c_str());
                    ui->debSIGFLGlineEdit->setText(num[4].c_str());
                    ui->debEPSFLGlineEdit->setText(num[5].c_str());
                    ui->debRLTFLGlineEdit->setText(num[6].c_str());
                    ui->debENGFLGlineEdit->setText(num[7].c_str());
                    ui->debCMPFLGlineEdit->setText(num[8].c_str());
                    ui->debIEVERPlineEdit->setText(num[9].c_str());
                    ui->debBEAMIPlineEdit->setText(num[10].c_str());
                    ui->debDCOMPlineEdit->setText(num[11].c_str());
                    ui->debSHGElineEdit->setText(num[12].c_str());
                    ui->debSTSSZlineEdit->setText(num[13].c_str());
                }

                else if (token == "*SET_PART_LIST")
                {
                    //std::cout << "DF" << std::endl;
                    std::getline(file, line);

                    if (line.find("$SET_PART_NAME: BLANK") != std::string::npos)
                    {

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 5, VAL_DIST);

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num2 = LoadValue(line, 8, VAL_DIST);

                        num.insert(num.end(), num2.begin(), num2.end());

                        ui->spl4SIDlineEdit->setText(num[0].c_str());
                        ui->spl4DA1lineEdit->setText(num[1].c_str());
                        ui->spl4DA2lineEdit->setText(num[2].c_str());
                        ui->spl4DA3lineEdit->setText(num[3].c_str());
                        ui->spl4DA4lineEdit->setText(num[4].c_str());
                        ui->spl4PID1lineEdit->setText(num[5].c_str());
                        ui->spl4PID2lineEdit->setText(num[6].c_str());
                        ui->spl4PID3lineEdit->setText(num[7].c_str());
                        ui->spl4PID4lineEdit->setText(num[8].c_str());
                        ui->spl4PID5lineEdit->setText(num[9].c_str());
                        ui->spl4PID6lineEdit->setText(num[10].c_str());
                        ui->spl4PID7lineEdit->setText(num[11].c_str());
                        ui->spl4PID8lineEdit->setText(num[12].c_str());
                    }

                    else if (line.find("$SET_PART_NAME: stol") != std::string::npos)
                    {

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 5, VAL_DIST);

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num2 = LoadValue(line, 8, VAL_DIST);

                        num.insert(num.end(), num2.begin(), num2.end());

                        ui->spl5SIDlineEdit->setText(num[0].c_str());
                        ui->spl5DA1lineEdit->setText(num[1].c_str());
                        ui->spl5DA2lineEdit->setText(num[2].c_str());
                        ui->spl5DA3lineEdit->setText(num[3].c_str());
                        ui->spl5DA4lineEdit->setText(num[4].c_str());
                        ui->spl5PID1lineEdit->setText(num[5].c_str());
                        ui->spl5PID2lineEdit->setText(num[6].c_str());
                        ui->spl5PID3lineEdit->setText(num[7].c_str());
                        ui->spl5PID4lineEdit->setText(num[8].c_str());
                        ui->spl5PID5lineEdit->setText(num[9].c_str());
                        ui->spl5PID6lineEdit->setText(num[10].c_str());
                        ui->spl5PID7lineEdit->setText(num[11].c_str());
                        ui->spl5PID8lineEdit->setText(num[12].c_str());
                    }
                }

                else if (token == "*PART")
                {
                    //std::cout << "DF" << std::endl;
                    std::getline(file, line);
                    std::getline(file, line);

                    if (line.find(" PART PID =        7 PART NAME :TOPSRF 1") != std::string::npos)
                    {

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                        ui->part4NAMElineEdit->setText("asdsd");
                        ui->part4PIDlineEdit->setText(num[0].c_str());
                        ui->part4SECIDlineEdit->setText(num[1].c_str());
                        ui->part4MIDlineEdit->setText(num[2].c_str());
                        ui->part4EOSIDlineEdit->setText(num[3].c_str());
                        ui->part4HGIDlineEdit->setText(num[4].c_str());
                        ui->part4GRAVlineEdit->setText(num[5].c_str());
                        ui->part4ADPOPTlineEdit->setText(num[6].c_str());
                        ui->part4TMIDlineEdit->setText(num[7].c_str());
                    }

                    else if (line.find(" PART PID =        3 PART NAME :DIE2") != std::string::npos)
                    {

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                        ui->part5NAMElineEdit->setText("asdsd");
                        ui->part5PIDlineEdit->setText(num[0].c_str());
                        ui->part5SECIDlineEdit->setText(num[1].c_str());
                        ui->part5MIDlineEdit->setText(num[2].c_str());
                        ui->part5EOSIDlineEdit->setText(num[3].c_str());
                        ui->part5HGIDlineEdit->setText(num[4].c_str());
                        ui->part5GRAVlineEdit->setText(num[5].c_str());
                        ui->part5ADPOPTlineEdit->setText(num[6].c_str());
                        ui->part5TMIDlineEdit->setText(num[7].c_str());
                    }
                }

                else if (token == "*MAT_TRANSVERSELY_ANISOTROPIC_ELASTIC_PLASTIC")
                {
                    std::getline(file, line);
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    ui->mtaep4MIDlineEdit->setText(num[0].c_str());
                    ui->mtaep4ROlineEdit->setText(num[1].c_str());
                    ui->mtaep4ElineEdit->setText(num[2].c_str());
                    ui->mtaep4PRlineEdit->setText(num[3].c_str());
                    ui->mtaep4SIGYlineEdit->setText(num[4].c_str());
                    ui->mtaep4ETANlineEdit->setText(num[5].c_str());
                    ui->mtaep4RlineEdit->setText(num[6].c_str());
                    ui->mtaep4HLCIDlineEdit->setText(num[7].c_str());

                    std::getline(file, line);

                    if (line.find("*SECTION_SHELL") != std::string::npos)
                    {
                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num2 = LoadValue(line, 5, VAL_DIST);

                        num.insert(num.end(), num2.begin(), num2.end());

                        ui->ss4SECIDlineEdit->setText(num[0].c_str());
                        ui->ss4ELFORMlineEdit->setText(num[1].c_str());
                        ui->ss4SHRFlineEdit->setText(num[2].c_str());
                        ui->ss4NIPlineEdit->setText(num[3].c_str());
                        ui->ss4PROPTlineEdit->setText(num[4].c_str());
                        ui->ss4QRIRIDlineEdit->setText(num[5].c_str());
                        ui->ss4ICOMPlineEdit->setText(num[6].c_str());
                        ui->ss4SETYPlineEdit->setText(num[7].c_str());
                        ui->ss4T1lineEdit->setText(num[8].c_str());
                        ui->ss4T2lineEdit->setText(num[9].c_str());
                        ui->ss4T3lineEdit->setText(num[10].c_str());
                        ui->ss4T4lineEdit->setText(num[11].c_str());
                        ui->ss4NLOClineEdit->setText(num[12].c_str());
                    }
                }

                else if (token == "*MAT_RIGID")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 3, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num3 = LoadValue(line, 6, VAL_DIST);

                    num.insert(num.end(), num3.begin(), num3.end());

                    ui->mr5MIDlineEdit->setText(num[0].c_str());
                    ui->mr5ROlineEdit->setText(num[1].c_str());
                    ui->mr5ElineEdit->setText(num[2].c_str());
                    ui->mr5PRlineEdit->setText(num[3].c_str());
                    ui->mr5NlineEdit->setText(num[4].c_str());
                    ui->mr5COUPLElineEdit->setText(num[5].c_str());
                    ui->mr5MlineEdit->setText(num[6].c_str());
                    ui->mr5ALIASlineEdit->setText(num[7].c_str());
                    ui->mr5CM0lineEdit->setText(num[8].c_str());
                    ui->mr5CON1lineEdit->setText(num[9].c_str());
                    ui->mr5CON2lineEdit->setText(num[10].c_str());
                    ui->mr5A1lineEdit->setText(num[11].c_str());
                    ui->mr5A2lineEdit->setText(num[12].c_str());
                    ui->mr5A3lineEdit->setText(num[13].c_str());
                    ui->mr5V1lineEdit->setText(num[14].c_str());
                    ui->mr5V2lineEdit->setText(num[15].c_str());
                    ui->mr5V3lineEdit->setText(num[16].c_str());

                    std::getline(file, line);

                    if (line.find("*SECTION_SHELL") != std::string::npos)
                    {
                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num2 = LoadValue(line, 5, VAL_DIST);

                        num.insert(num.end(), num2.begin(), num2.end());

                        ui->ss5SECIDlineEdit->setText(num[0].c_str());
                        ui->ss5ELFORMlineEdit->setText(num[1].c_str());
                        ui->ss5SHRFlineEdit->setText(num[2].c_str());
                        ui->ss5NIPlineEdit->setText(num[3].c_str());
                        ui->ss5PROPTlineEdit->setText(num[4].c_str());
                        ui->ss5QRIRIDlineEdit->setText(num[5].c_str());
                        ui->ss5ICOMPlineEdit->setText(num[6].c_str());
                        ui->ss5SETYPlineEdit->setText(num[7].c_str());
                        ui->ss5T1lineEdit->setText(num[8].c_str());
                        ui->ss5T2lineEdit->setText(num[9].c_str());
                        ui->ss5T3lineEdit->setText(num[10].c_str());
                        ui->ss5T4lineEdit->setText(num[11].c_str());
                        ui->ss5NLOClineEdit->setText(num[12].c_str());
                    }
                }

                else if (token == "*CONTACT_AUTOMATIC_SURFACE_TO_SURFACE_ID")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 2, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num3 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num3.begin(), num3.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num4 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num4.begin(), num4.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num5 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num5.begin(), num5.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num6 = LoadValue(line, 8, VAL_DIST);

                    num.insert(num.end(), num6.begin(), num6.end());

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num7 = LoadValue(line, 5, VAL_DIST);

                    num.insert(num.end(), num7.begin(), num7.end());

                    ui->castsi5CIDlineEdit->setText(num[0].c_str());
                    ui->castsi5CITlineEdit->setText(num[1].c_str());
                    ui->castsi5SSIDlineEdit->setText(num[2].c_str());
                    ui->castsi5MSIDlineEdit->setText(num[3].c_str());
                    ui->castsi5SSTYPlineEdit->setText(num[4].c_str());
                    ui->castsi5MSTYPlineEdit->setText(num[5].c_str());
                    ui->castsi5SBOXIDlineEdit->setText(num[6].c_str());
                    ui->castsi5MBOXIDlineEdit->setText(num[7].c_str());
                    ui->castsi5SPRlineEdit->setText(num[8].c_str());
                    ui->castsi5MPRlineEdit->setText(num[9].c_str());
                    ui->castsi5FSlineEdit->setText(num[10].c_str());
                    ui->castsi5FDlineEdit->setText(num[11].c_str());
                    ui->castsi5DClineEdit->setText(num[12].c_str());
                    ui->castsi5VClineEdit->setText(num[13].c_str());
                    ui->castsi5VDClineEdit->setText(num[14].c_str());
                    ui->castsi5PENCHKlineEdit->setText(num[15].c_str());
                    ui->castsi5BTlineEdit->setText(num[16].c_str());
                    ui->castsi5DTlineEdit->setText(num[17].c_str());
                    ui->castsi5SFSlineEdit->setText(num[18].c_str());
                    ui->castsi5SFMlineEdit->setText(num[19].c_str());
                    ui->castsi5SSTlineEdit->setText(num[20].c_str());
                    ui->castsi5MSTlineEdit->setText(num[21].c_str());
                    ui->castsi5SFSTlineEdit->setText(num[22].c_str());
                    ui->castsi5SFMTlineEdit->setText(num[23].c_str());
                    ui->castsi5FSFlineEdit->setText(num[24].c_str());
                    ui->castsi5VSFlineEdit->setText(num[25].c_str());
                    ui->castsi5SOFTlineEdit->setText(num[26].c_str());
                    ui->castsi5SOFSCLlineEdit->setText(num[27].c_str());
                    ui->castsi5LCIDABlineEdit->setText(num[28].c_str());
                    ui->castsi5MAXPARlineEdit->setText(num[29].c_str());
                    ui->castsi5PENTOLlineEdit->setText(num[30].c_str());
                    ui->castsi5DEPTHlineEdit->setText(num[31].c_str());
                    ui->castsi5BSORTlineEdit->setText(num[32].c_str());
                    ui->castsi5FRCFRQlineEdit->setText(num[33].c_str());
                    ui->castsi5PENMAXlineEdit->setText(num[34].c_str());
                    ui->castsi5THKOPTlineEdit->setText(num[35].c_str());
                    ui->castsi5SHLTHKlineEdit->setText(num[36].c_str());
                    ui->castsi5SNLOGlineEdit->setText(num[37].c_str());
                    ui->castsi5ISYMlineEdit->setText(num[38].c_str());
                    ui->castsi5I2D3DlineEdit->setText(num[39].c_str());
                    ui->castsi5SLDTHKlineEdit->setText(num[40].c_str());
                    ui->castsi5SLDSTFlineEdit->setText(num[41].c_str());
                    ui->castsi5IGAPlineEdit->setText(num[42].c_str());
                    ui->castsi5IGNORElineEdit->setText(num[43].c_str());
                    ui->castsi5DPRFAClineEdit->setText(num[44].c_str());
                    ui->castsi5DTSTIFlineEdit->setText(num[45].c_str());
                    ui->castsi5FLANGLlineEdit->setText(num[46].c_str());
                }

                else if (token == "*LOAD_MASK")
                {
                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num = LoadValue(line, 8, VAL_DIST);

                    std::getline(file, line);
                    std::getline(file, line);

                    std::vector<std::string> num2 = LoadValue(line, 1, VAL_DIST);

                    num.insert(num.end(), num2.begin(), num2.end());

                    ui->lmPIDlineEdit->setText(num[0].c_str());
                    ui->lmLCIDlineEdit->setText(num[1].c_str());
                    ui->lmVID1lineEdit->setText(num[2].c_str());
                    ui->lmOFFlineEdit->setText(num[3].c_str());
                    ui->lmBOXIDlineEdit->setText(num[4].c_str());
                    ui->lmLCIDMlineEdit->setText(num[5].c_str());
                    ui->lmVID2lineEdit->setText(num[6].c_str());
                    ui->lmINOUTlineEdit->setText(num[7].c_str());
                    ui->lmICYCLElineEdit->setText(num[8].c_str());
                }

                else if (token == "*DEFINE_CURVE")
                {
                    std::getline(file, line);

                    if (line.find("$D3PLOT") != std::string::npos)
                    {
                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 7, VAL_DIST);

                        std::getline(file, line);

                        for (int m = 0; m < 2; ++m)
                        {
                            std::getline(file, line);
                            std::vector<std::string> num2 = LoadValue(line, 2, 2*VAL_DIST);
                            num.insert(num.end(), num2.begin(), num2.end());
                        }

                        ui->dc1LCIDlineEdit->setText(num[0].c_str());
                        ui->dc1SIDRlineEdit->setText(num[1].c_str());
                        ui->dc1SCLAlineEdit->setText(num[2].c_str());
                        ui->dc1SCLOlineEdit->setText(num[3].c_str());
                        ui->dc1OFFAlineEdit->setText(num[4].c_str());
                        ui->dc1OFFOlineEdit->setText(num[5].c_str());
                        ui->dc1DATTYPlineEdit->setText(num[6].c_str());
                        for (int m = 0; m < 2; ++m)
                        {
                            ui->dc1A1comboBox->addItem(num[7+2*m].c_str());
                            ui->dc1O1comboBox->addItem(num[8+2*m].c_str());
                        }

                    }
                    else if (line.find("$SSC") != std::string::npos)
                    {
                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 7, VAL_DIST);

                        std::getline(file, line);

                        for (int m = 0; m < 101; ++m)
                        {
                            std::getline(file, line);
                            std::vector<std::string> num2 = LoadValue(line, 2, 2*VAL_DIST);
                            num.insert(num.end(), num2.begin(), num2.end());
                        }

                        ui->dc2LCIDlineEdit->setText(num[0].c_str());
                        ui->dc2SIDRlineEdit->setText(num[1].c_str());
                        ui->dc2SCLAlineEdit->setText(num[2].c_str());
                        ui->dc2SCLOlineEdit->setText(num[3].c_str());
                        ui->dc2OFFAlineEdit->setText(num[4].c_str());
                        ui->dc2OFFOlineEdit->setText(num[5].c_str());
                        ui->dc2DATTYPlineEdit->setText(num[6].c_str());
                        for (int m = 0; m < 101; ++m)
                        {
                            ui->dc2A1comboBox->addItem(num[7+2*m].c_str());
                            ui->dc2O1comboBox->addItem(num[8+2*m].c_str());
                        }

                    }
                    else if (line.find("$PRESSURE") != std::string::npos)
                    {
                        std::getline(file, line);
                        std::getline(file, line);

                        std::vector<std::string> num = LoadValue(line, 7, VAL_DIST);

                        std::getline(file, line);

                        for (int m = 0; m < 2; ++m)
                        {
                            std::getline(file, line);
                            std::vector<std::string> num2 = LoadValue(line, 2, 2*VAL_DIST);
                            num.insert(num.end(), num2.begin(), num2.end());
                        }

                        ui->dc3LCIDlineEdit->setText(num[0].c_str());
                        ui->dc3SIDRlineEdit->setText(num[1].c_str());
                        ui->dc3SCLAlineEdit->setText(num[2].c_str());
                        ui->dc3SCLOlineEdit->setText(num[3].c_str());
                        ui->dc3OFFAlineEdit->setText(num[4].c_str());
                        ui->dc3OFFOlineEdit->setText(num[5].c_str());
                        ui->dc3DATTYPlineEdit->setText(num[6].c_str());
                        for (int m = 0; m < 2; ++m)
                        {
                            ui->dc3A1comboBox->addItem(num[7+2*m].c_str());
                            ui->dc3O1comboBox->addItem(num[8+2*m].c_str());
                        }

                    }
                }

                else if (token == "*INCLUDE")
                {
                    std::getline(file, line);

                    ui->inc1lineEdit->setText(QString::fromStdString(line));

                    std::getline(file, line);
                    std::getline(file, line);
                    std::getline(file, line);

                    ui->inc2lineEdit->setText(QString::fromStdString(line));
                }
            }
        }

        props.clear();
    }

    file.close();
}
